package mysql

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	UserId     int     `gorm:"type:int(11);not null;comment:用户ID"`
	GoodsTitle string  `gorm:"type:varchar(30);not null;comment:商品标题"`
	GoodsPrice float32 `gorm:"type:float(10,2);not null;comment:商品价格"`
	GoodsImage string  `gorm:"type:varchar(255);not null;comment:商品图片"`
	GoodsType  int     `gorm:"type:int(1);not null;comment:商品类型: 0:电子数码,1:蔬菜,2:水果"`
	GoodsNum   int     `gorm:"type:int(30);not null;comment:商品库存"`
	GoodsColl  int     `gorm:"type:int(30);not null;comment:商品收藏数量"`
}

func (g *Goods) ListGoods(goodsId int) error {
	return DB.Where("goods_id = ?", goodsId).First(&g).Error
}
func (g *Goods) DetailsGoods(goodsId int) error {
	return DB.Where("id = ?", goodsId).First(&g).Error
}
